package com.muyu.cloud.system.service.impl;

import com.muyu.cloud.system.domain.BookInfo;
import com.muyu.cloud.system.mapper.BookInfoMapper;
import com.muyu.cloud.system.service.BookInfoService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: DongZeLiang
 * @date: 2024/5/23
 * @Description: 书籍业务实现层
 * @Version: 1.0
 */
@Service
@AllArgsConstructor
public class BookInfoServiceImpl implements BookInfoService {

    /**
     * 书籍持久层
     */
    private final BookInfoMapper bookInfoMapper;


    /**
     * 添加数据
     *
     * @param bookInfo 数据对象
     *
     * @return 返回添加的自增ID
     */
    @Override
    public int save (BookInfo bookInfo) {
        return bookInfoMapper.insert(bookInfo);
    }

    /**
     * 通过书籍ID查询书籍信息
     *
     * @param bookId 书籍ID
     *
     * @return 数据信息
     */
    @Override
    public BookInfo selectByBookId (Integer bookId) {
        return bookInfoMapper.selectByBookId(bookId);
    }

    /**
     * 通过书籍信息查询集合
     *
     * @param bookInfo 数据信息
     *
     * @return 符合集合内容
     */
    @Override
    public List<BookInfo> list (BookInfo bookInfo) {
        return bookInfoMapper.list(bookInfo);
    }

    /**
     * 通过ID修改书籍信息
     *
     * @param bookInfo 数据信息
     *
     * @return 修改条数
     */
    @Override
    public int updateByBookId (BookInfo bookInfo) {
        return bookInfoMapper.updateByBookId(bookInfo);
    }

    /**
     * 通过书籍ID删除书籍信息
     *
     * @param bookId 书籍ID
     *
     * @return 返回删除条数
     */
    @Override
    public int deleteByBookId (Integer bookId) {
        return bookInfoMapper.deleteByBookId(bookId);
    }
}
